//
//  GPSViewController.m
//  KKZ
//
//  Created by Zhang Chuyang on 11-7-28.
//  Copyright 2011年 Tsinghua University. All rights reserved.
//

#import "GPSViewController.h"
#import "UIViewController+BarItem.h"

@implementation GPSViewController

- (void)pop
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    mapView.showsUserLocation=YES;    
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];//创建位置管理器 
    locationManager.delegate=self;//设置代理 
    locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度级别 
    locationManager.distanceFilter=1000.0f;//设置距离筛选器 
    [locationManager startUpdatingLocation];//启动位置管理器 
    MKCoordinateSpan theSpan; 
    //地图的范围 越小越精确 
    theSpan.latitudeDelta=0.05; 
    theSpan.longitudeDelta=0.05; 
    MKCoordinateRegion theRegion; 
    theRegion.center=[[locationManager location] coordinate]; 
    theRegion.span=theSpan; 
    [mapView setRegion:theRegion]; 
    [locationManager release]; 
    
    [self addTitleToNavigationBar:@"GPS"];
    [self createBarItemOn:kNavBarItemSideLeft frame:kNavBarLeftItemFrame title:@"返回" target:self action:@selector(pop)];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
